<?php

namespace addons\csmitsm\library\xcore\xcore\utils;


class XcIncludeFileUtils
{
    private static $ROOT_PATH = ROOT_PATH;
    private static $ADDONS_PATH = ADDON_PATH . "/csmitsm/";

    public static function getAddonsPath($path)
    {
        return static::$ADDONS_PATH . $path;
    }
    public static function getRootPath($path)
    {
        return static::$ROOT_PATH . $path;
    }

    /**
     * include文件
        $sr = XcIncludeFileUtils::include_php_file("addons/csmitsm/config/xpConfig.php");
     * @return mixed
     */
    public static function include_php_file($filePath)
    {
        return include(static::$ROOT_PATH . $filePath);
    }

    /**
     * include文件(addons目录下)
        $sr = XcIncludeFileUtils::include_php_addons_file("config/xpConfig.php");
     * @return mixed
     */
    public static function include_php_addons_file($filePath)
    {
        return include(static::$ADDONS_PATH . $filePath);
    }

    /**
     * 读取INI
        $ini = XcIncludeFileUtils::parse_ini_file("addons/csmitsm/info.ini");
        echo $ini["name"];
     * @return array
     */
    public static function parse_ini_file($filePath)
    {
        return parse_ini_file(static::$ROOT_PATH . $filePath);
    }

    /**
     * 读取INI(addons目录下)
        $ini = XcIncludeFileUtils::parse_ini_file("info.ini");
        echo $ini["name"];
     * @return array
     */
    public static function parse_ini_addons_file($filePath)
    {
        return parse_ini_file(static::$ADDONS_PATH . $filePath);
    }
}
